function JCLightHTMLEditor(e){this.Init(e)}JCLightHTMLEditor.items={};JCLightHTMLEditor.prototype={Init:function(e){this.id=e.id;JCLightHTMLEditor.items[this.id]=this;var t=this;this.arConfig=e;this.bxTags={};this.bFocused=false;e.timeoutCount=e.timeoutCount||0;this.bPopup=false;this.buttonsIndex={};this.parseAlign=true;this.parseTable=true;this.lastCursorId="bxed-last-cursor";this.bHandleOnPaste=this.arConfig.bHandleOnPaste!==false;this.arBBTags=["p","u","div","table","tr","td","th","img","a","center","left","right","justify"];this._turnOffCssCount=0;if(this.arConfig.arBBTags)this.arBBTags=this.arBBTags.concat(this.arConfig.arBBTags);this.arConfig.width=this.arConfig.width?parseInt(this.arConfig.width)+(this.arConfig.width.indexOf("%")==-1?"px":"%"):"100%";this.arConfig.height=this.arConfig.height?parseInt(this.arConfig.height)+(this.arConfig.height.indexOf("%")==-1?"px":"%"):"100%";this.SetConstants();this.sEditorMode="html";this.toolbarLineCount=1;this.CACHE={};this.arVideos={};this.content=this.arConfig.content;this.oSpecialParsers={};BX.onCustomEvent(window,"LHE_OnBeforeParsersInit",[this]);this.oSpecialParsers.cursor={Parse:function(e,t,i){return t.replace(/#BXCURSOR#/gi,'<span id="'+i.lastCursorId+'"></span>')},UnParse:function(e,t,i){return"#BXCURSOR#"}};if(e.parsers){for(var i in e.parsers){if(e.parsers[i])this.oSpecialParsers[i]=e.parsers[i]}}this.bDialogOpened=false;this.pFrame=BX("bxlhe_frame_"+this.id);if(!this.pFrame){if(e.timeoutCount<100){setTimeout((function(){e.timeoutCount++;t.Init(e)}),1)}return}this.pFrame.style.display="block";this.pFrame.style.width=this.arConfig.width;this.pFrame.style.height=this.arConfig.height;this.pFrameTable=this.pFrame.firstChild;this.pButtonsCell=this.pFrameTable.rows[0].cells[0];this.pButtonsCont=this.pButtonsCell.firstChild;this.pEditCont=this.pFrameTable.rows[1].cells[0];if(this.arConfig.height.indexOf("%")==-1){var r=parseInt(this.arConfig.height)-this.toolbarLineCount*27;if(r>0)this.pEditCont.style.height=r+"px"}this.CreateFrame();this.pSourceDiv=this.pEditCont.appendChild(BX.create("DIV",{props:{className:"lha-source-div"}}));this.pTextarea=this.pSourceDiv.appendChild(BX.create("TEXTAREA",{props:{className:"lha-textarea",rows:25,id:this.arConfig.inputId}}));this.pHiddenInput=this.pFrame.appendChild(BX.create("INPUT",{props:{type:"hidden",name:this.arConfig.inputName}}));this.pTextarea.onfocus=function(){t.bTextareaFocus=true};this.pTextarea.onblur=function(){t.bTextareaFocus=false};this.pTextarea.style.fontFamily=this.arConfig.fontFamily;this.pTextarea.style.fontSize=this.arConfig.fontSize;this.pTextarea.style.fontSize=this.arConfig.lineHeight;if(this.pHiddenInput.form){BX.bind(this.pHiddenInput.form,"submit",(function(){try{t.SaveContent();t.pHiddenInput.value=t.pTextarea.value=t.pHiddenInput.value.replace(/#BXCURSOR#/gi,"")}catch(e){}}))}if(this.arConfig.arSmiles&&this.arConfig.arSmiles.length>0){this.sortedSmiles=[];var s,n,o,a,l,h;for(s=0,n=this.arConfig.arSmiles.length;s<n;s++){o=this.arConfig.arSmiles[s];if(!o["codes"]||o["codes"]==o["code"]){this.sortedSmiles.push(o)}else if(o["codes"].length>0){h=o["codes"].split(" ");for(a=0,l=h.length;a<l;a++)this.sortedSmiles.push({name:o.name,path:o.path,code:h[a]})}}this.sortedSmiles=this.sortedSmiles.sort((function(e,t){return t.code.length-e.code.length}))}if(!this.arConfig.bBBCode&&this.arConfig.bConvertContentFromBBCodes)this.arConfig.bBBCode=true;this.bBBCode=this.arConfig.bBBCode;if(this.bBBCode){if(this.InitBBCode&&typeof this.InitBBCode=="function")this.InitBBCode()}this.bBBParseImageSize=this.arConfig.bBBParseImageSize;if(this.arConfig.bResizable){if(this.arConfig.bManualResize){this.pResizer=BX("bxlhe_resize_"+this.id);this.pResizer.title=BX.message.ResizerTitle;if(!this.arConfig.minHeight||parseInt(this.arConfig.minHeight)<=0)this.arConfig.minHeight=100;if(!this.arConfig.maxHeight||parseInt(this.arConfig.maxHeight)<=0)this.arConfig.maxHeight=2e3;this.pResizer.unselectable="on";this.pResizer.ondragstart=function(e){return BX.PreventDefault(e)};this.pResizer.onmousedown=function(){t.InitResizer();return false}}if(this.arConfig.bAutoResize){BX.bind(this.pTextarea,"keydown",BX.proxy(this.AutoResize,this));BX.addCustomEvent(this,"onShow",BX.proxy(this.AutoResize,this))}}this.AddButtons();this.parseAlign=!this.arConfig.bBBCode||!!(this.buttonsIndex["Justify"]||this.buttonsIndex["JustifyLeft"]);this.parseTable=!this.arConfig.bBBCode||!!this.buttonsIndex["Table"];if(!this.parseAlign||!this.parseTable){var d=[];for(var l in this.arBBTags){if(!this.parseAlign&&(this.arBBTags[l]=="center"||this.arBBTags[l]=="left"||this.arBBTags[l]=="right"||this.arBBTags[l]=="justify"))continue;if(!this.parseTable&&(this.arBBTags[l]=="table"||this.arBBTags[l]=="tr"||this.arBBTags[l]=="td"||this.arBBTags[l]=="th"))continue;d.push(this.arBBTags[l])}this.arBBTags=d}this.SetContent(this.content);this.SetEditorContent(this.content);this.oTransOverlay=new LHETransOverlay({},this);BX.onCustomEvent(window,"LHE_OnInit",[this,false]);BX.bind(this.pEditorDocument,"click",BX.proxy(this.OnClick,this));BX.bind(this.pEditorDocument,"mousedown",BX.proxy(this.OnMousedown,this));if(this.arConfig.bSaveOnBlur)BX.bind(document,"mousedown",BX.proxy(this.OnDocMousedown,this));if(this.arConfig.ctrlEnterHandler&&typeof window[this.arConfig.ctrlEnterHandler]=="function")this.ctrlEnterHandler=window[this.arConfig.ctrlEnterHandler];if(BX.browser.IsAndroid()&&/Android\s[1-3].[0-9]/i.test(navigator.userAgent)){this.arConfig.bSetDefaultCodeView=true}if(this.arConfig.bSetDefaultCodeView){if(this.sourseBut)this.sourseBut.oBut.handler(this.sourseBut);else this.SetView("code")}BX.ready((function(){if(t.pFrame.offsetWidth==0&&t.pFrame.offsetWidth==0){t.onShowInterval=setInterval((function(){if(t.pFrame.offsetWidth!=0&&t.pFrame.offsetWidth!=0){BX.onCustomEvent(t,"onShow");clearInterval(t.onShowInterval)}}),500)}else{BX.onCustomEvent(t,"onShow")}}));this.adjustBodyInterval=1e3;this._AdjustBodyWidth();BX.removeClass(this.pButtonsCont,"lhe-stat-toolbar-cont-preload")},CreateFrame:function(){if(this.iFrame&&this.iFrame.parentNode){this.pEditCont.removeChild(this.iFrame);this.iFrame=null}this.iFrame=this.pEditCont.appendChild(BX.create("IFRAME",{props:{id:"LHE_iframe_"+this.id,className:"lha-iframe",src:"javascript:void(0)",frameborder:0}}));if(this.iFrame.contentDocument&&!BX.browser.IsIE())this.pEditorDocument=this.iFrame.contentDocument;else this.pEditorDocument=this.iFrame.contentWindow.document;this.pEditorWindow=this.iFrame.contentWindow},ReInit:function(e){if(typeof e=="undefined")e="";this.SetContent(e);this.CreateFrame();this.SetEditorContent(this.content);this.SetFocus();BX.onCustomEvent(window,"LHE_OnInit",[this,true])},SetConstants:function(){this.reBlockElements=/^(TITLE|TABLE|SCRIPT|TR|TBODY|H1|H2|H3|H4|H5|H6|ADDRESS|PRE|OL|UL|LI)$/i;this.oneGif=this.arConfig.oneGif;this.imagePath=this.arConfig.imagePath;if(!this.arConfig.fontFamily){const e=BX("bxlhe_frame_"+this.id);const t=e?e:document.body;const i=BX.Dom.style(t,"--ui-font-family-primary");const r=BX.Dom.style(t,"--ui-font-family-helvetica");const s=BX.Type.isStringFilled(i)?i:r;if(BX.Type.isStringFilled(s)){this.arConfig.fontFamily=s}}if(!this.arConfig.fontSize)this.arConfig.fontSize="14px";if(!this.arConfig.lineHeight)this.arConfig.lineHeight="16px";this.arColors=["#FF0000","#FFFF00","#00FF00","#00FFFF","#0000FF","#FF00FF","#FFFFFF","#EBEBEB","#E1E1E1","#D7D7D7","#CCCCCC","#C2C2C2","#B7B7B7","#ACACAC","#A0A0A0","#959595","#EE1D24","#FFF100","#00A650","#00AEEF","#2F3192","#ED008C","#898989","#7D7D7D","#707070","#626262","#555","#464646","#363636","#262626","#111","#000000","#F7977A","#FBAD82","#FDC68C","#FFF799","#C6DF9C","#A4D49D","#81CA9D","#7BCDC9","#6CCFF7","#7CA6D8","#8293CA","#8881BE","#A286BD","#BC8CBF","#F49BC1","#F5999D","#F16C4D","#F68E54","#FBAF5A","#FFF467","#ACD372","#7DC473","#39B778","#16BCB4","#00BFF3","#438CCB","#5573B7","#5E5CA7","#855FA8","#A763A9","#EF6EA8","#F16D7E","#EE1D24","#F16522","#F7941D","#FFF100","#8FC63D","#37B44A","#00A650","#00A99E","#00AEEF","#0072BC","#0054A5","#2F3192","#652C91","#91278F","#ED008C","#EE105A","#9D0A0F","#A1410D","#A36209","#ABA000","#588528","#197B30","#007236","#00736A","#0076A4","#004A80","#003370","#1D1363","#450E61","#62055F","#9E005C","#9D0039","#790000","#7B3000","#7C4900","#827A00","#3E6617","#045F20","#005824","#005951","#005B7E","#003562","#002056","#0C004B","#30004A","#4B0048","#7A0045","#7A0026"];this.systemCSS="img.bxed-anchor{background-image: url("+this.imagePath+"lhe_iconkit.gif)!important; background-position: -260px 0!important; height: 20px!important; width: 20px!important;}\n"+"body{font-family:"+this.arConfig.fontFamily+"; font-size: "+this.arConfig.fontSize+"; line-height:"+this.arConfig.lineHeight+"; color: #151515;}\n"+"p{padding:0!important; margin: 0!important;}\n"+"span.bxed-noscript{color: #0000a0!important; padding: 2px!important; font-style:italic!important; font-size: 90%!important;}\n"+"span.bxed-noindex{color: #004000!important; padding: 2px!important; font-style:italic!important; font-size: 90%!important;}\n"+"img.bxed-flash{border: 1px solid #B6B6B8!important; background: url("+this.imagePath+"flash.gif) #E2DFDA center center no-repeat !important;}\n"+"table{border: 1px solid #B6B6B8!important; border-collapse: collapse;}\n"+"table td{border: 1px solid #B6B6B8!important; padding: 2px 5px;}\n"+"img.bxed-video{border: 1px solid #B6B6B8!important; background-color: #E2DFDA!important; background-image: url("+this.imagePath+"video.gif); background-position: center center!important; background-repeat:no-repeat!important;}\n"+"img.bxed-hr{padding: 2px!important; width: 100%!important; height: 2px!important;}\n";if(this.arConfig.documentCSS)this.systemCSS+="\n"+this.arConfig.documentCSS;this.tabNbsp="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";this.tabNbspRe1=new RegExp(String.fromCharCode(160)+String.fromCharCode(160)+String.fromCharCode(160)+String.fromCharCode(160)+String.fromCharCode(160)+String.fromCharCode(160),"ig");this.tabNbspRe2=new RegExp(String.fromCharCode(160)+String.fromCharCode(160)+String.fromCharCode(160)+String.fromCharCode(160)+String.fromCharCode(160)+" ","ig")},OnMousedown:function(e){if(!e)e=window.event;this.bFocused=true},OnClick:function(e){this.bFocused=true;this.CheckBr()},OnDblClick:function(e){return},OnContextMenu:function(e,t){return;var i=this,r,s,n;if(!e)e=this.pEditorWindow.event;if(e.pageX||e.pageY){s=e.pageX-this.pEditorDocument.body.scrollLeft;n=e.pageY-this.pEditorDocument.body.scrollTop}else if(e.clientX||e.clientY){s=e.clientX;n=e.clientY}r=this.CACHE["frame_pos"];if(!r)this.CACHE["frame_pos"]=r=BX.pos(this.pEditCont);s+=r.left;n+=r.top;var o;if(e.target)o=e.target;else if(e.srcElement)o=e.srcElement;if(o.nodeType==3)o=o.parentNode;if(!o||!o.nodeName)return;var a=this.oContextMenu.Show({oPos:{left:s,top:n},pElement:o});return BX.PreventDefault(e)},OnKeyDown:function(e){if(!e)e=window.event;BX.onCustomEvent(this,"OnDocumentKeyDown",[e]);var t=e.which||e.keyCode;if(e.ctrlKey&&!e.shiftKey&&!e.altKey){switch(t){case 66:case 98:this.executeCommand("Bold");return BX.PreventDefault(e);case 105:case 73:this.executeCommand("Italic");return BX.PreventDefault(e);case 117:case 85:this.executeCommand("Underline");return BX.PreventDefault(e);case 81:if(this.quoteBut){this.quoteBut.oBut.handler(this.quoteBut);return BX.PreventDefault(e)}}}if(this.bHandleOnPaste&&(e.ctrlKey&&!e.shiftKey&&!e.altKey&&e.keyCode==86||!e.ctrlKey&&e.shiftKey&&!e.altKey&&e.keyCode==45||e.metaKey&&!e.shiftKey&&!e.altKey&&e.keyCode==86)){this.OnPaste()}if(this.bCodeBut&&e.shiftKey&&e.keyCode==46){var i=this.GetSelectionObject();if(i){if(i.className=="lhe-code"){i.parentNode.removeChild(i);return BX.PreventDefault(e)}else if(i.parentNode){var r=BX.findParent(i,{className:"lhe-code"});if(r){r.parentNode.removeChild(r);return BX.PreventDefault(e)}}}}if(t==9&&this.arConfig.bReplaceTabToNbsp){this.InsertHTML(this.tabNbsp);return BX.PreventDefault(e)}if(this.bCodeBut&&e.keyCode==13){if(BX.browser.IsIE()||BX.browser.IsSafari()||BX.browser.IsChrome()){var s=this.GetSelectionObject();if(s){var n=false;if(s&&s.nodeName&&s.nodeName.toLowerCase()=="pre")n=true;if(!n)n=!!BX.findParent(s,{tagName:"pre"});if(n){if(BX.browser.IsIE())this.InsertHTML('<br/><img src="'+this.oneGif+'" height="20" width="1"/>');else if(BX.browser.IsSafari()||BX.browser.IsChrome())this.InsertHTML(" \r\n");return BX.PreventDefault(e)}}}}if((e.keyCode==13||e.keyCode==10)&&e.ctrlKey&&this.ctrlEnterHandler){this.SaveContent();this.ctrlEnterHandler()}if(this.arConfig.bAutoResize&&this.arConfig.bResizable){if(this._resizeTimeout){clearTimeout(this._resizeTimeout);this._resizeTimeout=null}this._resizeTimeout=setTimeout(BX.proxy(this.AutoResize,this),200)}if(this._CheckBrTimeout){clearTimeout(this._CheckBrTimeout);this._CheckBrTimeout=null}this._CheckBrTimeout=setTimeout(BX.proxy(this.CheckBr,this),1e3)},OnDocMousedown:function(e){if(this.bFocused){if(!e)e=window.event;var t;if(e.target)t=e.target;else if(e.srcElement)t=e.srcElement;if(t.nodeType==3)t=t.parentNode;if(!this.bPopup&&!BX.findParent(t,{className:"bxlhe-frame"})){this.SaveContent();this.bFocused=false}}},SetView:function(e){if(this.sEditorMode==e)return;this.SaveContent();if(e=="code"){this.iFrame.style.display="none";this.pSourceDiv.style.display="block";this.SetCodeEditorContent(this.GetContent())}else{this.iFrame.style.display="block";this.pSourceDiv.style.display="none";this.SetEditorContent(this.GetContent());this.CheckBr()}this.sEditorMode=e;BX.onCustomEvent(this,"OnChangeView")},SaveContent:function(){var e=this.sEditorMode=="code"?this.GetCodeEditorContent():this.GetEditorContent();if(this.bBBCode)e=this.OptimizeBB(e);this.SetContent(e);BX.onCustomEvent(this,"OnSaveContent",[e])},SetContent:function(e){this.pHiddenInput.value=this.pTextarea.value=this.content=e},GetContent:function(){return this.content.toString()},SetEditorContent:function(e){if(this.pEditorDocument){e=this.ParseContent(e);if(this.pEditorDocument.designMode){try{this.pEditorDocument.designMode="off"}catch(e){alert("SetEditorContent: designMode='off'")}}this.pEditorDocument.open();this.pEditorDocument.write("<html><head></head><body>"+e+"</body></html>");this.pEditorDocument.close();this.pEditorDocument.body.style.padding="8px";this.pEditorDocument.body.style.margin="0";this.pEditorDocument.body.style.borderWidth="0";this.pEditorDocument.body.style.fontFamily=this.arConfig.fontFamily;this.pEditorDocument.body.style.fontSize=this.arConfig.fontSize;this.pEditorDocument.body.style.lineHeight=this.arConfig.lineHeight;BX.bind(this.pEditorDocument,"keydown",BX.proxy(this.OnKeyDown,this));if(BX.browser.IsIE()){if(this.bHandleOnPaste)BX.bind(this.pEditorDocument.body,"paste",BX.proxy(this.OnPaste,this));this.pEditorDocument.body.contentEditable=true}else if(this.pEditorDocument.designMode){this.pEditorDocument.designMode="on";this._TurnOffStyleWithCSS(true)}if(this.arConfig.bConvertContentFromBBCodes)this.ShutdownBBCode()}},_TurnOffStyleWithCSS:function(e){try{this._turnOffCssCount++;if(this._turnOffCssCount<5&&e!==false)e=true;this.pEditorDocument.execCommand("styleWithCSS",false,false);try{this.pEditorDocument.execCommand("useCSS",false,true)}catch(e){}}catch(t){if(e===true)setTimeout(BX.proxy(this._TurnOffStyleWithCSS,this),500)}},_AdjustBodyWidth:function(){if(!BX.browser.IsChrome()){if(this.pEditorDocument&&this.pEditorDocument.body){var e=this.pEditorDocument.body.innerHTML;if(e!=this.lastEditedBodyHtml){this.adjustBodyInterval=500;var t=this;this.pEditorDocument.body.style.width=null;this.lastEditedBodyHtml=e;setTimeout((function(){var e=BX.GetWindowScrollSize(t.pEditorDocument).scrollWidth-16;if(e>0)t.pEditorDocument.body.style.width=e+"px"}),50)}else{this.adjustBodyInterval=5e3}}setTimeout(BX.proxy(this._AdjustBodyWidth,this),this.adjustBodyInterval)}},GetEditorContent:function(){var e=this.UnParseContent();return e},SetCodeEditorContent:function(e){this.pHiddenInput.value=this.pTextarea.value=e},GetCodeEditorContent:function(){return this.pTextarea.value},OptimizeHTML:function(e){var t=0,i=true,r=["b","em","font","h\\d","i","li","ol","p","small","span","strong","u","ul"],s=function(){a--;i=true;return" "},n,o,a,l;while(t++<20&&i){i=false;for(a=0,l=r.length;a<l;a++){o=r[a];n=new RegExp("<"+o+"[^>]*?>\\s*?</"+o+">","ig");e=e.replace(n,s);n=new RegExp("<"+o+"\\s+?[^>]*?/>","ig");e=e.replace(n,s);n=new RegExp("<(("+o+"+?)(?:\\s+?[^>]*?)?)>([\\s\\S]+?)<\\/\\2>\\s*?<\\1>([\\s\\S]+?)<\\/\\2>","ig");e=e.replace(n,(function(e,t,r,s,n){i=true;return"<"+t+">"+s+" "+n+"</"+r+">"}))}}return e},_RecursiveDomWalker:function(e,t){var i={arAttributes:{},arNodes:[],type:null,text:"",arStyle:{}};switch(e.nodeType){case 9:i.type="document";break;case 1:if(e.tagName.length<=0||e.tagName.substring(0,1)=="/")return;i.text=e.tagName.toLowerCase();if(i.text=="script")break;i.type="element";var r=e.attributes,s,n=r.length;if(e.nodeName.toLowerCase()=="a"&&e.innerHTML==""&&(this.bBBCode||!e.getAttribute("name")))return;for(s=0;s<n;s++){if(r[s].specified||i.text=="input"&&r[s].nodeName.toLowerCase()=="value"){var o=r[s].nodeName.toLowerCase();if(o=="style"){i.arAttributes[o]=e.style.cssText;i.arStyle=e.style;if(i.arStyle.display=="none"){i.type="text";i.text="";break}if(i.arStyle.textAlign&&(i.text=="div"||i.text=="p"||i.text=="span")){var a=i.arStyle.textAlign;BX.util.in_array(i.arStyle.textAlign,["left","right","center","justify"]);{i.arStyle={};i.text="span";i.arAttributes["style"]="text-align:"+a+";display:block;";i.arStyle.textAlign=a;i.arStyle.display="block"}}}else if(o=="src"||o=="href"||o=="width"||o=="height"){i.arAttributes[o]=e.getAttribute(o,2)}else if(!this.bBBCode&&o=="align"&&BX.util.in_array(r[s].nodeValue,["left","right","center","justify"])){i.text="span";i.arAttributes["style"]="text-align:"+r[s].nodeValue+";display:block;";i.arStyle.textAlign=r[s].nodeValue;i.arStyle.display="block"}else{i.arAttributes[o]=r[s].nodeValue}}}break;case 3:i.type="text";var l=e.nodeValue;if(this.arConfig.bReplaceTabToNbsp){l=l.replace(this.tabNbspRe1,"\t");l=l.replace(this.tabNbspRe2,"\t")}if(!t||t.text!="pre"&&t.arAttributes["class"]!="lhe-code"){l=l.replace(/\n+/g," ");l=l.replace(/ +/g," ")}i.text=l;break}if(i.type!="text"){var h=e.childNodes,d,n=h.length;for(d=0;d<n;d++)i.arNodes.push(this._RecursiveDomWalker(h[d],i))}return i},_RecursiveGetHTML:function(e){if(!e||typeof e!="object"||!e.arAttributes)return"";var t,i="",r=e.arAttributes["id"];if(e.text=="img"&&!r)r=this.SetBxTag(false,{tag:"img",params:{src:e.arAttributes["src"]}});if(r){var s=this.GetBxTag(r);if(s.tag){var n=this.oSpecialParsers[s.tag];if(n&&n.UnParse)return n.UnParse(s,e,this);else if(s.params&&s.params.value)return"\n"+s.params.value+"\n";else return""}}if(e.arAttributes["_moz_editor_bogus_node"])return"";if(this.bBBCode){var o=this.UnParseNodeBB(e);if(o!==false)return o}bFormatted=true;if(e.text.toLowerCase()!="body")i=this.GetNodeHTMLLeft(e);var a=false;var l="";if(typeof e.bFormatted!="undefined")bFormatted=!!e.bFormatted;if(bFormatted&&e.type!="text"){if(this.reBlockElements.test(e.text)&&!(e.oParent&&e.oParent.text&&e.oParent.text.toLowerCase()=="pre")){for(var h=0;h<e.iLevel-3;h++)l+="  ";a=true;i="\r\n"+l+i}}for(var d=0;d<e.arNodes.length;d++)i+=this._RecursiveGetHTML(e.arNodes[d]);if(e.text.toLowerCase()!="body")i+=this.GetNodeHTMLRight(e);if(a)i+="\r\n"+(l==""?"":l.substr(2));return i},GetNodeHTMLLeft:function(e){if(e.type=="text")return BX.util.htmlspecialchars(e.text);var t,i,r;if(e.type=="element"){r="<"+e.text;for(i in e.arAttributes){t=e.arAttributes[i];if(i.substring(0,4).toLowerCase()=="_moz")continue;if(e.text.toUpperCase()=="BR"&&i.toLowerCase()=="type"&&t=="_moz")continue;if(i=="style"){if(t.length>0&&t.indexOf("-moz")!=-1)t=BX.util.trim(t.replace(/-moz.*?;/gi,""));if(e.text=="td")t=BX.util.trim(t.replace(/border-image:\s*none;/gi,""));if(t.length<=0)continue}r+=" "+i+'="'+(e.bDontUseSpecialchars?t:BX.util.htmlspecialchars(t))+'"'}if(e.arNodes.length<=0&&!this.IsPairNode(e.text))return r+" />";return r+">"}return""},GetNodeHTMLRight:function(e){if(e.type=="element"&&(e.arNodes.length>0||this.IsPairNode(e.text)))return"</"+e.text+">";return""},IsPairNode:function(e){if(e.substr(0,1)=="h"||e=="br"||e=="img"||e=="input")return false;return true},executeCommand:function(e,t){this.SetFocus();var i=this.pEditorWindow.document.execCommand(e,false,t);this.SetFocus();if(this.arConfig.bAutoResize&&this.arConfig.bResizable)this.AutoResize();return i},queryCommand:function(e){var t="";if(!this.pEditorDocument.queryCommandEnabled||!this.pEditorDocument.queryCommandValue)return null;if(!this.pEditorDocument.queryCommandEnabled(e))return null;return this.pEditorDocument.queryCommandValue(e)},SetFocus:function(){if(this.sEditorMode!="html")return;BX.focus(this.pEditorWindow.focus?this.pEditorWindow:this.pEditorDocument.body);this.bFocused=true},SetFocusToEnd:function(){this.CheckBr();var e=BX.GetWindowScrollSize(this.pEditorDocument);this.pEditorWindow.scrollTo(0,e.scrollHeight);this.SetFocus();this.SelectElement(this.pEditorDocument.body.lastChild)},SetCursorFF:function(){if(this.sEditorMode!="code"&&!BX.browser.IsIE()){var e=this;try{this.iFrame.blur();this.iFrame.focus();setTimeout((function(){e.iFrame.blur();e.iFrame.focus()}),600);setTimeout((function(){e.iFrame.blur();e.iFrame.focus()}),1e3)}catch(e){}}},CheckBr:function(){if(this.CheckBrTimeout){clearTimeout(this.CheckBrTimeout);this.CheckBrTimeout=false}var e=this;this.CheckBrTimeout=setTimeout((function(){var t=e.pEditorDocument.body.lastChild;if(t&&t.nodeType==1){var i=t.nodeName.toUpperCase();var r=/^(TITLE|TABLE|SCRIPT|DIV|H1|H2|H3|H4|H5|H6|ADDRESS|PRE|OL|UL|LI|BLOCKQUOTE|FORM|CENTER|)$/i;if(r.test(i))e.pEditorDocument.body.appendChild(e.pEditorDocument.createElement("BR"))}}),200)},ParseContent:function(e,t){var i=this;var r=[];e=e.replace(/\[code\]((?:\s|\S)*?)\[\/code\]/gi,(function(e,t){var s="";if(!i.bBBCode)s=' id="'+i.SetBxTag(false,{tag:"code"})+'" ';r.push("<pre "+s+'class="lhe-code" title="'+BX.message.CodeDel+'">'+BX.util.htmlspecialchars(t)+"</pre>");return"#BX_CODE"+(r.length-1)+"#"}));if(!t)BX.onCustomEvent(this,"OnParseContent");if(this.arConfig.bBBCode)e=this.ParseBB(e);e=e.replace(/(<td[^>]*>)\s*(<\/td>)/gi,'$1<br _moz_editor_bogus_node="on">$2');if(this.arConfig.bReplaceTabToNbsp)e=e.replace(/\t/gi,this.tabNbsp);if(!BX.browser.IsIE()){e=e.replace(/<hr[^>]*>/gi,(function(e){return'<img class="bxed-hr" src="'+i.imagePath+'break_page.gif" id="'+i.SetBxTag(false,{tag:"hr",params:{value:e}})+'"/>'}))}for(var s in this.oSpecialParsers){if(this.oSpecialParsers[s]&&this.oSpecialParsers[s].Parse)e=this.oSpecialParsers[s].Parse(s,e,this)}if(!t)setTimeout((function(){i.AppendCSS(i.systemCSS);setTimeout((function(){i.pEditorDocument.body.style.fontFamily="";i.pEditorDocument.body.style.fontSize=""}),1)}),300);if(r.length>0)e=e.replace(/#BX_CODE(\d+)#/gi,(function(e,t){return r[t]||e}));if(this.bBBCode){e=e.replace(/&amp;#91;/gi,"[");e=e.replace(/&amp;#93;/gi,"]")}e=BX.util.trim(e);if(this.arConfig.bBBCode&&!e.match(/(<br[^>]*>)$/gi))e+="<br/>";return e},UnParseContent:function(){BX.onCustomEvent(this,"OnUnParseContent");var e=this._RecursiveGetHTML(this._RecursiveDomWalker(this.pEditorDocument.body,false));if(this.bBBCode){if(!BX.browser.IsIE())e=e.replace(/\r/gi,"");e=e.replace(/\n/gi,"")}var t=[["#BR#(#TAG_BEGIN#)","$1"],["(#TAG_BEGIN#)(?:#BR#)*?(#TAG_END#)","$1$2"],["(#TAG_BEGIN#)([\\s\\S]*?)#TAG_END#(?:\\n|\\r|\\s)*?#TAG_BEGIN#([\\s\\S]*?)(#TAG_END#)",function(e,t,i,r,s){return t+i+"#BR#"+r+s},true],["^#TAG_BEGIN#",""],["([\\s\\S]*?(\\[\\/\\w+\\])*?)#TAG_BEGIN#([\\s\\S]*?)#TAG_END#([\\s\\S]*?)",function(e,t,i,r,s){if(i&&i.toLowerCase&&i.toLowerCase()=="[/list]")return t+r+"#BR#"+s;return t+"#BR#"+r+"#BR#"+s},true],["#TAG_END#","#BR#"]];var i,r,s=t.length,n;if(this.bBBCode){if(BX.browser.IsOpera())e=e.replace(/(?:#BR#)*?\[\/P\]/gi,"[/P]");for(r=0;r<s;r++){i=t[r][0];i=i.replace(/#TAG_BEGIN#/g,"\\[P\\]");i=i.replace(/#TAG_END#/g,"\\[\\/P\\]");i=i.replace(/\\\\/gi,"\\\\");i=new RegExp(i,"igm");if(t[r][2]===true)while(true){n=e.replace(i,t[r][1]);if(n==e)break;else e=n}else e=e.replace(i,t[r][1])}e=e.replace(/^((?:\s|\S)*?)(?:\n|\r|\s)+$/gi,"$1\n\n");for(r=0;r<s;r++){i=t[r][0];i=i.replace(/#TAG_BEGIN#/g,"\\[DIV\\]");i=i.replace(/#TAG_END#/g,"\\[\\/DIV\\]");i=i.replace(/\\\\/gi,"\\\\");if(t[r][2]===true)while(true){n=e.replace(new RegExp(i,"igm"),t[r][1]);if(n==e)break;else e=n}else e=e.replace(new RegExp(i,"igm"),t[r][1])}e=e.replace(/#BR#/gi,"\n");e=e.replace(/\[DIV]/gi,"");e=BX.util.htmlspecialcharsback(e)}this.__sContent=e;BX.onCustomEvent(this,"OnUnParseContentAfter");e=this.__sContent;return e},InitResizer:function(){this.oTransOverlay.Show();var e=this,t=BX.pos(this.pFrame),i=false;var r=function(r){r=r||window.event;BX.fixEventPageY(r);i=r.pageY-t.top;if(i<e.arConfig.minHeight){i=e.arConfig.minHeight;document.body.style.cursor="not-allowed"}else if(i>e.arConfig.maxHeight){i=e.arConfig.maxHeight;document.body.style.cursor="not-allowed"}else{document.body.style.cursor="n-resize"}e.pFrame.style.height=i+"px";e.ResizeFrame(i)};var s=function(t){if(e.arConfig.autoResizeSaveSize)BX.userOptions.save("fileman","LHESize_"+e.id,"height",i);e.arConfig.height=i;document.body.style.cursor="";if(e.oTransOverlay&&e.oTransOverlay.bShowed)e.oTransOverlay.Hide();BX.unbind(document,"mousemove",r);BX.unbind(document,"mouseup",s)};BX.bind(document,"mousemove",r);BX.bind(document,"mouseup",s)},AutoResize:function(){var e=parseInt(this.arConfig.autoResizeOffset||80),t=parseInt(this.arConfig.autoResizeMaxHeight||0),i=parseInt(this.arConfig.autoResizeMinHeight||50),r,s=this;if(this.autoResizeTimeout)clearTimeout(this.autoResizeTimeout);this.autoResizeTimeout=setTimeout((function(){if(s.sEditorMode=="html"){r=s.pEditorDocument.body.offsetHeight;var n=s.pEditorDocument.body,o=n.lastChild,a=false,l;while(true){if(!o)break;if(o.offsetTop){a=o.offsetTop+(o.offsetHeight||0);r=a+e;break}else{o=o.previousSibling}}var h=BX.GetWindowSize(s.pEditorDocument);if(h.scrollHeight-h.innerHeight>5)r=Math.max(h.scrollHeight+e,r)}else{r=(s.pTextarea.value.split("\n").length+5)*17}if(r>parseInt(s.arConfig.height)){if(BX.browser.IsIOS())t=Infinity;else if(!t||t<10)t=Math.round(BX.GetWindowInnerSize().innerHeight*.9);r=Math.min(r,t);r=Math.max(r,i);s.SmoothResizeFrame(r)}}),300)},MousePos:function(e){if(window.event)e=window.event;if(e.pageX||e.pageY){e.realX=e.pageX;e.realY=e.pageY}else if(e.clientX||e.clientY){e.realX=e.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft)-document.documentElement.clientLeft;e.realY=e.clientY+(document.documentElement.scrollTop||document.body.scrollTop)-document.documentElement.clientTop}return e},SmoothResizeFrame:function(e){var t=this,i=parseInt(this.pFrame.offsetHeight),r=0,s=e>i,n=BX.browser.IsIE()?50:50,o=5;if(!s)return;if(this.smoothResizeInterval)clearInterval(this.smoothResizeInterval);this.smoothResizeInterval=setInterval((function(){if(s){i+=Math.round(o*r);if(i>e){clearInterval(t.smoothResizeInterval);if(i>e)i=e}}else{i-=Math.round(o*r);if(i<e){i=e;clearInterval(t.smoothResizeInterval)}}t.pFrame.style.height=i+"px";t.ResizeFrame(i);r++}),n)},ResizeFrame:function(e){var t=7,i=this.arConfig.bManualResize?3:0,r=e||parseInt(this.pFrame.offsetHeight),s=this.pFrame.offsetWidth;this.pFrameTable.style.height=r+"px";var n=r-this.buttonsHeight-i;if(n>0){this.pEditCont.style.height=n+"px";this.pTextarea.style.height=n+"px"}this.pTextarea.style.width=s>t?s-t+"px":"auto";this.pButtonsCell.style.height=this.buttonsHeight+"px"},AddButtons:function(){var e,t,i,r,s,n=this.arConfig.toolbarConfig;this.buttonsCount=0;if(!n)n=["Bold","Italic","Underline","Strike","RemoveFormat","InsertHR","Anchor","CreateLink","DeleteLink","Image","Justify","InsertOrderedList","InsertUnorderedList","Outdent","Indent","BackColor","ForeColor","Video","StyleList","HeaderList","FontList","FontSizeList","Table"];if(oBXLEditorUtils.oTune&&oBXLEditorUtils.oTune[this.id]){var o=oBXLEditorUtils.oTune[this.id].ripButtons,a=oBXLEditorUtils.oTune[this.id].buttons;if(o){e=0;while(e<n.length){if(o[n[e]])n=BX.util.deleteFromArray(n,e);else e++}}if(a){for(var l=0,h=a.length;l<h;l++){if(a[l].ind==-1||a[l].ind>=n.length)n.push(a[l].but.id);else n=BX.util.insertIntoArray(n,a[l].ind,a[l].but.id)}}}var d=0,f=0,c=d,u,p=parseInt(this.pButtonsCont.offsetWidth);this.ToolbarStartLine(true);for(e in n){i=n[e];if(typeof i!="string"||!n.hasOwnProperty(e))continue;if(i=="=|="){this.ToolbarNewLine();c=d}else if(LHEButtons[i]){if(this.bBBCode&&LHEButtons[i].bBBHide)continue;this.buttonsIndex[i]=e;u=this.AddButton(LHEButtons[i],i);if(u){c+=parseInt(u.style.width)||23;if(c+f>p&&p>0){p=parseInt(this.pButtonsCont.offsetWidth);if(c+f>p&&p>0){this.ToolbarNewLine();this.pButtonsCont.appendChild(u);c=d}}}}}this.ToolbarEndLine();if(typeof this.arConfig.controlButtonsHeight=="undefined")this.buttonsHeight=this.toolbarLineCount*27;else this.buttonsHeight=parseInt(this.arConfig.controlButtonsHeight||0);this.arConfig.minHeight+=this.buttonsHeight;this.arConfig.maxHeight+=this.buttonsHeight;BX.addCustomEvent(this,"onShow",BX.proxy(this.ResizeFrame,this))},AddButton:function(e,t){if(e.parser&&e.parser.obj)this.oSpecialParsers[e.parser.name]=e.parser.obj;this.buttonsCount++;var i;if(!e.type||!e.type=="button"){if(t=="Code")this.bCodeBut=true;var r=new window.LHEButton(e,this);if(r&&r.oBut){if(t=="Source")this.sourseBut=r;else if(t=="Quote")this.quoteBut=r;i=this.pButtonsCont.appendChild(r.pCont)}}else if(e.type=="Colorpicker"){var s=new window.LHEColorPicker(e,this);i=this.pButtonsCont.appendChild(s.pCont)}else if(e.type=="List"){var n=new window.LHEList(e,this);i=this.pButtonsCont.appendChild(n.pCont)}if(e.parsers){for(var o=0,a=e.parsers.length;o<a;o++)if(e.parsers[o]&&e.parsers[o].obj)this.oSpecialParsers[e.parsers[o].name]=e.parsers[o].obj}return i},AddParser:function(e){if(e&&e.name&&typeof e.obj=="object")this.oSpecialParsers[e.name]=e.obj},ToolbarStartLine:function(e){if(!e&&BX.browser.IsIE())this.pButtonsCont.appendChild(BX.create("IMG",{props:{src:this.oneGif,className:"lhe-line-ie"}}));this.pButtonsCont.appendChild(BX.create("DIV",{props:{className:"lhe-line-begin"}}))},ToolbarEndLine:function(){this.pButtonsCont.appendChild(BX.create("DIV",{props:{className:"lhe-line-end"}}))},ToolbarNewLine:function(){this.toolbarLineCount++;this.ToolbarEndLine();this.ToolbarStartLine()},OpenDialog:function(e){var t=new window.LHEDialog(e,this)},GetSelectionObject:function(){var e,t,i;if(this.pEditorDocument.selection){e=this.pEditorDocument.selection;t=e.createRange();if(e.type=="Control")return t.commonParentElement();return t.parentElement()}else{e=this.pEditorWindow.getSelection();if(!e)return false;var r,s,n=e.rangeCount,o;for(var s=0;s<n;s++){t=e.getRangeAt(s);r=t.startContainer;if(r.nodeType!=3){if(r.nodeType==1&&r.childNodes.length<=0)o=r;else o=r.childNodes[t.startOffset]}else{temp=t.commonAncestorContainer;while(temp&&temp.nodeType==3)temp=temp.parentNode;o=temp}i=s==0?o:BXFindParentElement(i,o)}return i}},GetSelectionObjects:function(){var e;if(this.pEditorDocument.selection){e=this.pEditorDocument.selection;var t=e.createRange();if(e.type=="Control")return t.commonParentElement();return t.parentElement()}else{e=this.pEditorWindow.getSelection();if(!e)return false;var i;var r,s;var n=[];for(var o=0;o<e.rangeCount;o++){i=e.getRangeAt(o);r=i.startContainer;if(r.nodeType!=3){if(r.nodeType==1&&r.childNodes.length<=0)n[n.length]=r;else n[n.length]=r.childNodes[i.startOffset]}else{s=i.commonAncestorContainer;while(s&&s.nodeType==3)s=s.parentNode;n[n.length]=s}}if(n.length>1)return n;return n[0]}},GetSelectionRange:function(e,t){try{var i=e||this.pEditorDocument,r=t||this.pEditorWindow,s,n=this.GetSelection(i,r);if(n){if(i.createRange){if(n.getRangeAt)s=n.getRangeAt(0);else{s=document.createRange();s.setStart(n.anchorNode,n.anchorOffset);s.setEnd(n.focusNode,n.focusOffset)}}else s=n.createRange()}else{s=false}}catch(e){s=false}return s},SelectRange:function(e,t,i){try{if(!e)return;var r=t||this.pEditorDocument,s=i||this.pEditorWindow;this.ClearSelection(r,s);if(r.createRange){var n=s.getSelection();n.removeAllRanges();n.addRange(e)}else{e.select()}}catch(e){}},SelectElement:function(e){try{var t,i=this.pEditorDocument,r=this.pEditorWindow;if(r.getSelection){var s=r.getSelection();s.selectAllChildren(e);t=s.getRangeAt(0);if(t.selectNode)t.selectNode(e)}else{i.selection.empty();t=i.selection.createRange();t.moveToElementText(e);t.select()}return t}catch(e){}},GetSelectedText:function(e){var t="";if(e.startContainer&&e.endContainer){if(e.startContainer==e.endContainer&&(e.endContainer.nodeType==3||e.endContainer.nodeType==1))t=e.startContainer.textContent.substring(e.startOffset,e.endOffset)}else{if(e.text==e.htmlText)t=e.text}return t||""},ClearSelection:function(e,t){var i=e||this.pEditorDocument,r=t||this.pEditorWindow;if(r.getSelection)r.getSelection().removeAllRanges();else i.selection.empty()},GetSelection:function(e,t){if(!e)e=document;if(!t)t=window;var i=false;if(t.getSelection)i=t.getSelection();else if(e.getSelection)i=e.getSelection();else if(e.selection)i=e.selection;return i},InsertHTML:function(e){try{this.SetFocus();if(BX.browser.IsIE()){var t=this.pEditorDocument.selection.createRange();if(t.pasteHTML){t.pasteHTML(e);t.collapse(false);t.select()}}else if(BX.browser.IsIE11()){this.PasteHtmlAtCaret(e)}else{this.pEditorWindow.document.execCommand("insertHTML",false,e)}}catch(e){}if(this.arConfig.bAutoResize&&this.arConfig.bResizable)this.AutoResize()},PasteHtmlAtCaret:function(e,t){var i=this.pEditorWindow,r=this.pEditorDocument,s,n;if(i.getSelection){s=i.getSelection();if(s.getRangeAt&&s.rangeCount){n=s.getRangeAt(0);n.deleteContents();var o=r.createElement("div");o.innerHTML=e;var a=r.createDocumentFragment(),l,h;while(l=o.firstChild)h=a.appendChild(l);var d=a.firstChild;n.insertNode(a);if(h){n=n.cloneRange();n.setStartAfter(h);if(t)n.setStartBefore(d);else n.collapse(true);s.removeAllRanges();s.addRange(n)}}}else if((s=r.selection)&&s.type!="Control"){var f=s.createRange();f.collapse(true);s.createRange().pasteHTML(e);if(t){n=s.createRange();n.setEndPoint("StartToStart",f);n.select()}}},AppendCSS:function(e){e=BX.util.trim(e);if(e.length<=0)return false;var t=this.pEditorDocument,i=t.getElementsByTagName("HEAD");if(i.length!=1)return false;if(BX.browser.IsIE()){setTimeout((function(){try{if(t.styleSheets.length==0)i[0].appendChild(t.createElement("STYLE"));t.styleSheets[0].cssText+=e}catch(e){}}),100)}else{try{var r=t.createElement("STYLE");i[0].appendChild(r);r.appendChild(t.createTextNode(e))}catch(e){}}return true},SetBxTag:function(e,t){var i;if(t.id||e&&e.id)i=t.id||e.id;if(!i)i="bxid_"+Math.round(Math.random()*1e6);else if(this.bxTags[i]&&!t.tag)t.tag=this.bxTags[i].tag;t.id=i;if(e)e.id=t.id;this.bxTags[t.id]=t;return t.id},GetBxTag:function(e){if(e){if(typeof e!="string"&&e.id)e=e.id;if(e&&e.length>0&&this.bxTags[e]&&this.bxTags[e].tag){this.bxTags[e].tag=this.bxTags[e].tag.toLowerCase();return this.bxTags[e]}}return{tag:false}},GetAttributesList:function(e){e=e+" ";var t={},i=[],r=false,s=this;e=e.replace(/<\?.*?\?>/gi,(function(e){i.push(e);return"#BXPHP"+(i.length-1)+"#"}));e=e.replace(/([^\w]??)(\w+?)=([^\s\'"]+?)(\s)/gi,(function(e,r,s,n,o){n=n.replace(/#BXPHP(\d+)#/gi,(function(e,t){return i[t]||e}));t[s.toLowerCase()]=BX.util.htmlspecialcharsback(n);return r}));e=e.replace(/([^\w]??)(\w+?)\s*=\s*("|\')([^\3]*?)\3/gi,(function(e,r,s,n,o){o=o.replace(/#BXPHP(\d+)#/gi,(function(e,t){return i[t]||e}));t[s.toLowerCase()]=BX.util.htmlspecialcharsback(o);return r}));return t},RidOfNode:function(e,t){if(!e||e.nodeType!=1)return;var i,r=e.tagName.toLowerCase(),s=["span","strike","del","font","code","div"];if(BX.util.in_array(r,s)){if(t!==true){for(i=e.attributes.length-1;i>=0;i--){if(BX.util.trim(e.getAttribute(e.attributes[i].nodeName.toLowerCase()))!="")return false}}var n=e.childNodes;while(n.length>0)e.parentNode.insertBefore(n[0],e);e.parentNode.removeChild(e);return true}return false},WrapSelectionWith:function(e,t){this.SetFocus();var i,r;if(!e)e="SPAN";var s="FONT",n,o,a,l=[];try{this.pEditorDocument.execCommand("styleWithCSS",false,false)}catch(e){}this.executeCommand("FontName","bitrixtemp");a=this.pEditorDocument.getElementsByTagName(s);for(n=a.length-1;n>=0;n--){if(a[n].getAttribute("face")!="bitrixtemp")continue;o=BX.create(e,t,this.pEditorDocument);l.push(o);while(a[n].firstChild)o.appendChild(a[n].firstChild);a[n].parentNode.insertBefore(o,a[n]);a[n].parentNode.removeChild(a[n])}if(this.arConfig.bAutoResize&&this.arConfig.bResizable)this.AutoResize();return l},SaveSelectionRange:function(){if(this.sEditorMode=="code")this.oPrevRangeText=this.GetSelectionRange(document,window);else this.oPrevRange=this.GetSelectionRange()},RestoreSelectionRange:function(){if(this.sEditorMode=="code")this.IESetCarretPos(this.oPrevRangeText);else if(this.oPrevRange)this.SelectRange(this.oPrevRange)},focus:function(e,t){setTimeout((function(){try{e.focus();if(t)e.select()}catch(e){}}),100)},InitBBCode:function(){this.stack=[];var e=this;this.pTextarea.onkeydown=BX.proxy(this.OnKeyDownBB,this);this._GetNodeHTMLLeft=this.GetNodeHTMLLeft;this._GetNodeHTMLRight=this.GetNodeHTMLRight;this.GetNodeHTMLLeft=this.GetNodeHTMLLeftBB;this.GetNodeHTMLRight=this.GetNodeHTMLRightBB},ShutdownBBCode:function(){this.bBBCode=false;this.arConfig.bBBCode=false;this.pTextarea.onkeydown=null;this.GetNodeHTMLLeft=this._GetNodeHTMLLeft;this.GetNodeHTMLRight=this._GetNodeHTMLRight;this.arConfig.bConvertContentFromBBCodes=false},FormatBB:function(e){var t=e.pBut,i=e.value,r=e.tag.toUpperCase(),s=r;if(r=="FONT"||r=="COLOR"||r=="SIZE")r+="="+i;if((!BX.util.in_array(r,this.stack)||this.GetTextSelection())&&!(r=="FONT"&&i=="none")){if(!this.WrapWith("["+r+"]","[/"+s+"]")){this.stack.push(r);if(t&&t.Check)t.Check(true)}}else{var n=false;while(n=this.stack.pop()){this.WrapWith("[/"+n+"]","");if(t&&t.Check)t.Check(false);if(n==r)break}}},GetTextSelection:function(){var e=false;if(typeof this.pTextarea.selectionStart!="undefined"){e=this.pTextarea.value.substr(this.pTextarea.selectionStart,this.pTextarea.selectionEnd-this.pTextarea.selectionStart)}else if(document.selection&&document.selection.createRange){e=document.selection.createRange().text}else if(window.getSelection){e=window.getSelection();e=e.toString()}return e},IESetCarretPos:function(e){if(!e||!BX.browser.IsIE()||e.text.length!=0)return;e.moveStart("character",-this.pTextarea.value.length);var t=e.text.length;var i=this.pTextarea.createTextRange();i.collapse(true);i.moveEnd("character",t);i.moveStart("character",t);i.select()},WrapWith:function(e,t,i){if(!e)e="";if(!t)t="";if(!i)i="";if(e.length<=0&&t.length<=0&&i.length<=0)return true;var r=!!i;var s=this.GetTextSelection();if(!this.bTextareaFocus)this.pTextarea.focus();var n=s?"select":r?"after":"in";if(r)i=e+i+t;else if(s)i=e+s+t;else i=e+t;if(typeof this.pTextarea.selectionStart!="undefined"){var o=this.pTextarea.scrollTop,a=this.pTextarea.selectionStart,l=this.pTextarea.selectionEnd;this.pTextarea.value=this.pTextarea.value.substr(0,a)+i+this.pTextarea.value.substr(l);if(n=="select"){this.pTextarea.selectionStart=a;this.pTextarea.selectionEnd=a+i.length}else if(n=="in"){this.pTextarea.selectionStart=this.pTextarea.selectionEnd=a+e.length}else{this.pTextarea.selectionStart=this.pTextarea.selectionEnd=a+i.length}this.pTextarea.scrollTop=o}else if(document.selection&&document.selection.createRange){var h=document.selection.createRange();var d=h.duplicate();i=i.replace(/\r?\n/g,"\n");h.text=i;h.setEndPoint("StartToStart",d);h.setEndPoint("EndToEnd",d);if(n=="select"){h.collapse(true);i=i.replace(/\r\n/g,"1");h.moveEnd("character",i.length)}else if(n=="in"){h.collapse(false);h.moveEnd("character",e.length);h.collapse(false)}else{h.collapse(false);h.moveEnd("character",i.length);h.collapse(false)}h.select()}else{this.pTextarea.value+=i}return true},ParseBB:function(e){e=BX.util.htmlspecialchars(e);e=e.replace(/[\r\n\s\t]?\[table\][\r\n\s\t]*?\[tr\]/gi,"[TABLE][TR]");e=e.replace(/\[tr\][\r\n\s\t]*?\[td\]/gi,"[TR][TD]");e=e.replace(/\[tr\][\r\n\s\t]*?\[th\]/gi,"[TR][TH]");e=e.replace(/\[\/td\][\r\n\s\t]*?\[td\]/gi,"[/TD][TD]");e=e.replace(/\[\/tr\][\r\n\s\t]*?\[tr\]/gi,"[/TR][TR]");e=e.replace(/\[\/td\][\r\n\s\t]*?\[\/tr\]/gi,"[/TD][/TR]");e=e.replace(/\[\/th\][\r\n\s\t]*?\[\/tr\]/gi,"[/TH][/TR]");e=e.replace(/\[\/tr\][\r\n\s\t]*?\[\/table\][\r\n\s\t]?/gi,"[/TR][/TABLE]");e=e.replace(/[\r\n\s\t]*?\[\/list\]/gi,"[/LIST]");e=e.replace(/[\r\n\s\t]*?\[\*\]?/gi,"[*]");var t=["b","u","i",["s","del"],"table","tr","td","th"],i,r,s,n=t.length,o;for(s=0;s<n;s++){if(typeof t[s]=="object"){i=t[s][0];r=t[s][1]}else{i=r=t[s]}e=e.replace(new RegExp("\\[(\\/?)"+i+"\\]","ig"),"<$1"+r+">")}e=e.replace(/\[url\]((?:\s|\S)*?)\[\/url\]/gi,'<a href="$1">$1</a>');e=e.replace(/\[url\s*=\s*((?:[^\[\]]*?(?:\[[^\]]+?\])*[^\[\]]*?)*)\s*\]((?:\s|\S)*?)\[\/url\]/gi,'<a href="$1">$2</a>');var a=this;e=e.replace(/\[img(?:\s*?width=(\d+)\s*?height=(\d+))?\]((?:\s|\S)*?)\[\/img\]/gi,(function(e,t,i,r){var s="";t=parseInt(t);i=parseInt(i);if(t&&i&&a.bBBParseImageSize)s=' width="'+t+'" height="'+i+'"';return'<img  src="'+r+'"'+s+"/>"}));s=0;while(e.toLowerCase().indexOf("[color=")!=-1&&e.toLowerCase().indexOf("[/color]")!=-1&&s++<20)e=e.replace(/\[color=((?:\s|\S)*?)\]((?:\s|\S)*?)\[\/color\]/gi,'<font color="$1">$2</font>');s=0;while(e.toLowerCase().indexOf("[list=")!=-1&&e.toLowerCase().indexOf("[/list]")!=-1&&s++<20)e=e.replace(/\[list=1\]((?:\s|\S)*?)\[\/list\]/gi,"<ol>$1</ol>");s=0;while(e.toLowerCase().indexOf("[list")!=-1&&e.toLowerCase().indexOf("[/list]")!=-1&&s++<20)e=e.replace(/\[list\]((?:\s|\S)*?)\[\/list\]/gi,"<ul>$1</ul>");e=e.replace(/\[\*\]/gi,"<li>");s=0;while(e.toLowerCase().indexOf("[font=")!=-1&&e.toLowerCase().indexOf("[/font]")!=-1&&s++<20)e=e.replace(/\[font=((?:\s|\S)*?)\]((?:\s|\S)*?)\[\/font\]/gi,'<font face="$1">$2</font>');s=0;while(e.toLowerCase().indexOf("[size=")!=-1&&e.toLowerCase().indexOf("[/size]")!=-1&&s++<20)e=e.replace(/\[size=((?:\s|\S)*?)\]((?:\s|\S)*?)\[\/size\]/gi,'<font size="$1">$2</font>');e=e.replace(/\n/gi,"<br />");return e},UnParseNodeBB:function(e){if(e.text=="br")return"#BR#";if(e.type=="text")return false;if(e.text=="pre"&&e.arAttributes["class"]=="lhe-code")return"[CODE]"+this.RecGetCodeContent(e)+"[/CODE]";e.bbHide=true;if(e.text=="font"&&e.arAttributes.color){e.bbHide=false;e.text="color";e.bbValue=e.arAttributes.color}else if(e.text=="font"&&e.arAttributes.size){e.bbHide=false;e.text="size";e.bbValue=e.arAttributes.size}else if(e.text=="font"&&e.arAttributes.face){e.bbHide=false;e.text="font";e.bbValue=e.arAttributes.face}else if(e.text=="del"){e.bbHide=false;e.text="s"}else if(e.text=="strong"||e.text=="b"){e.bbHide=false;e.text="b"}else if(e.text=="em"||e.text=="i"){e.bbHide=false;e.text="i"}else if(e.text=="blockquote"){e.bbHide=false;e.text="quote"}else if(e.text=="ol"){e.bbHide=false;e.text="list";e.bbBreakLineRight=true;e.bbValue="1"}else if(e.text=="ul"){e.bbHide=false;e.text="list";e.bbBreakLineRight=true}else if(e.text=="li"){e.bbHide=false;e.text="*";e.bbBreakLine=true;e.bbHideRight=true}else if(e.text=="a"){e.bbHide=false;e.text="url";e.bbValue=e.arAttributes.href}else if(this.parseAlign&&(e.arAttributes.align||e.arStyle.textAlign)&&!BX.util.in_array(e.text.toLowerCase(),["table","tr","td","th"])){var t=e.arStyle.textAlign||e.arAttributes.align;if(BX.util.in_array(t,["left","right","center","justify"])){e.bbHide=false;e.text=t}else{e.bbHide=!BX.util.in_array(e.text,this.arBBTags)}}else if(BX.util.in_array(e.text,this.arBBTags)){e.bbHide=false}return false},RecGetCodeContent:function(e){if(!e||!e.arNodes||!e.arNodes.length)return"";var t="";for(var i=0;i<e.arNodes.length;i++){if(e.arNodes[i].type=="text")t+=e.arNodes[i].text;else if(e.arNodes[i].type=="element"&&e.arNodes[i].text=="br")t+=this.bBBCode?"#BR#":"\n";else if(e.arNodes[i].arNodes)t+=this.RecGetCodeContent(e.arNodes[i])}if(this.bBBCode){if(BX.browser.IsIE())t=t.replace(/\r/gi,"#BR#");else t=t.replace(/\n/gi,"#BR#")}else if(BX.browser.IsIE()){t=t.replace(/\n/gi,"\r\n")}return t},GetNodeHTMLLeftBB:function(e){if(e.type=="text"){var t=BX.util.htmlspecialchars(e.text);t=t.replace(/\[/gi,"&#91;");t=t.replace(/\]/gi,"&#93;");return t}var i="";if(e.bbBreakLine)i+="\n";if(e.type=="element"&&!e.bbHide){i+="["+e.text.toUpperCase();if(e.bbValue)i+="="+e.bbValue;i+="]"}return i},GetNodeHTMLRightBB:function(e){var t="";if(e.bbBreakLineRight)t+="\n";if(e.type=="element"&&(e.arNodes.length>0||this.IsPairNode(e.text))&&!e.bbHide&&!e.bbHideRight)t+="[/"+e.text.toUpperCase()+"]";return t},OptimizeBB:function(e){var t=0,i=true,r=["b","i","u","s","color","font","size","quote"],s=function(){a--;i=true;return" "},n,o,a,l;while(t++<20&&i){i=false;for(a=0,l=r.length;a<l;a++){o=r[a];n=new RegExp("\\["+o+"[^\\]]*?\\]\\s*?\\[/"+o+"\\]","ig");e=e.replace(n,s);if(o!=="quote"){n=new RegExp("\\[(("+o+"+?)(?:\\s+?[^\\]]*?)?)\\]([\\s\\S]+?)\\[\\/\\2\\](\\s*?)\\[\\1\\]([\\s\\S]+?)\\[\\/\\2\\]","ig");e=e.replace(n,(function(e,t,r,s,n,o){if(n.indexOf("\n")!=-1)return e;i=true;return"["+t+"]"+s+" "+o+"[/"+r+"]"}))}}}e=e.replace(/[\r\n\s\t]*?\[\/list\]/gi,"\n[/LIST]");e=e.replace(/[\r\n\s\t]*?\[\/list\]/gi,"\n[/LIST]");e=e.replace(/\n*$/gi,"");return e},RemoveFormatBB:function(){var e=this.GetTextSelection();if(e){var t=0,i=["b","i","u","s","color","font","size"],r,s=i.length;while(t<30){str1=e;for(r=0;r<s;r++)e=e.replace(new RegExp("\\[("+i[r]+")[^\\]]*?\\]([\\s\\S]*?)\\[/\\1\\]","ig"),"$2");if(e==str1)break;t++}this.WrapWith("","",e)}},OnKeyDownBB:function(e){if(!e)e=window.event;var t=e.which||e.keyCode;if(e.ctrlKey&&!e.shiftKey&&!e.altKey){switch(t){case 66:case 98:this.FormatBB({tag:"B"});return BX.PreventDefault(e);case 105:case 73:this.FormatBB({tag:"I"});return BX.PreventDefault(e);case 117:case 85:this.FormatBB({tag:"U"});return BX.PreventDefault(e);case 81:this.FormatBB({tag:"QUOTE"});return BX.PreventDefault(e)}}if(t==9){this.WrapWith("","","\t");return BX.PreventDefault(e)}if((e.keyCode==13||e.keyCode==10)&&e.ctrlKey&&this.ctrlEnterHandler){this.SaveContent();this.ctrlEnterHandler()}},GetCutHTML:function(e){if(this.curCutId){var t=this.pEditorDocument.getElementById(this.curCutId);if(t){t.parentNode.insertBefore(BX.create("BR",{},this.pEditorDocument),t);t.parentNode.removeChild(t)}}this.curCutId=this.SetBxTag(false,{tag:"cut"});return'<img src="'+this.oneGif+'" class="bxed-cut" id="'+this.curCutId+'" title="'+BX.message.CutTitle+'"/>'},OnPaste:function(){if(this.bOnPasteProcessing)return;this.bOnPasteProcessing=true;var e=this;var t=this.pEditorDocument.body.scrollTop;setTimeout((function(){e.bOnPasteProcessing=false;e.InsertHTML('<span style="visibility: hidden;" id="'+e.SetBxTag(false,{tag:"cursor"})+'" ></span>');e.SaveContent();setTimeout((function(){var i=e.GetContent();if(/<\w[^>]*(( class="?MsoNormal"?)|(="mso-))/gi.test(i))i=e.CleanWordText(i);e.SetEditorContent(i);setTimeout((function(){try{var i=e.pEditorDocument.getElementById(e.lastCursorId);if(i&&i.parentNode){var r=i.offsetTop-30;if(r>0){if(t>0&&t+parseInt(e.pFrame.offsetHeight)>r)e.pEditorDocument.body.scrollTop=t;else e.pEditorDocument.body.scrollTop=r}e.SelectElement(i);i.parentNode.removeChild(i);e.SetFocus()}}catch(e){}}),100)}),100)}),100)},CleanWordText:function(e){e=e.replace(/<(P|B|U|I|STRIKE)>&nbsp;<\/\1>/g," ");e=e.replace(/<o:p>([\s\S]*?)<\/o:p>/gi,"$1");e=e.replace(/<span[^>]*display:\s*?none[^>]*>([\s\S]*?)<\/span>/gi,"");e=e.replace(/<!--\[[\s\S]*?\]-->/gi,"");e=e.replace(/<!\[[\s\S]*?\]>/gi,"");e=e.replace(/<\\?\?xml[^>]*>/gi,"");e=e.replace(/<o:p>\s*<\/o:p>/gi,"");e=e.replace(/<\/?[a-z1-9]+:[^>]*>/gi,"");e=e.replace(/<([a-z1-9]+[^>]*) class=([^ |>]*)(.*?>)/gi,"<$1$3");e=e.replace(/<([a-z1-9]+[^>]*) [a-z]+:[a-z]+=([^ |>]*)(.*?>)/gi,"<$1$3");e=e.replace(/&nbsp;/gi," ");e=e.replace(/\s+?/gi," ");e=e.replace(/\s*mso-[^:]+:[^;"]+;?/gi,"");e=e.replace(/\s*margin: 0cm 0cm 0pt\s*;/gi,"");e=e.replace(/\s*margin: 0cm 0cm 0pt\s*"/gi,'"');e=e.replace(/\s*TEXT-INDENT: 0cm\s*;/gi,"");e=e.replace(/\s*TEXT-INDENT: 0cm\s*"/gi,'"');e=e.replace(/\s*TEXT-ALIGN: [^\s;]+;?"/gi,'"');e=e.replace(/\s*PAGE-BREAK-BEFORE: [^\s;]+;?"/gi,'"');e=e.replace(/\s*FONT-VARIANT: [^\s;]+;?"/gi,'"');e=e.replace(/\s*tab-stops:[^;"]*;?/gi,"");e=e.replace(/\s*tab-stops:[^"]*/gi,"");e=e.replace(/<FONT[^>]*>([\s\S]*?)<\/FONT>/gi,"$1");e=e.replace(/\s*face="[^"]*"/gi,"");e=e.replace(/\s*face=[^ >]*/gi,"");e=e.replace(/\s*FONT-FAMILY:[^;"]*;?/gi,"");e=e.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi,"<$1$3");e=e.replace(/<(\w[^>]*) style="([^\"]*)"([^>]*)/gi,"<$1$3");e=e.replace(/\s*style="\s*"/gi,"");e=e.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi,"<$1$3");var t=0;while(e.toLowerCase().indexOf("<span")!=-1&&e.toLowerCase().indexOf("</span>")!=-1&&t++<20)e=e.replace(/<span[^>]*?>([\s\S]*?)<\/span>/gi,"$1");var i,r,s,n=["b","strong","i","u","font","span","strike"];while(true){i=e;for(r in n){s=n[r];e=e.replace(new RegExp("<"+s+"[^>]*?>(\\s*?)<\\/"+s+">","gi"),"$1");e=e.replace(new RegExp("<\\/"+s+"[^>]*?>(\\s*?)<"+s+">","gi"),"$1")}if(i==e)break}e=e.replace(/<(?:[^\s>]+)[^>]*>([\s\n\t\r]*)<\/\1>/g,"$1");e=e.replace(/<(?:[^\s>]+)[^>]*>(\s*)<\/\1>/g,"$1");e=e.replace(/<(?:[^\s>]+)[^>]*>(\s*)<\/\1>/g,"$1");e=e.replace(/<xml[^>]*?(?:>\s*?<\/xml)?(?:\/?)?>/gi,"");e=e.replace(/<meta[^>]*?(?:>\s*?<\/meta)?(?:\/?)?>/gi,"");e=e.replace(/<link[^>]*?(?:>\s*?<\/link)?(?:\/?)?>/gi,"");e=e.replace(/<style[\s\S]*?<\/style>/gi,"");e=e.replace(/<table([\s\S]*?)>/gi,"<table>");e=e.replace(/<tr([\s\S]*?)>/gi,"<tr>");e=e.replace(/(<td[\s\S]*?)width=("|')[\s\S]*?\2([\s\S]*?>)/gi,"$1$3");e=e.replace(/(<td[\s\S]*?)height=("|')[\s\S]*?\2([\s\S]*?>)/gi,"$1$3");e=e.replace(/(<td[\s\S]*?)style=("|')[\s\S]*?\2([\s\S]*?>)/gi,"$1$3");e=e.replace(/(<td[\s\S]*?)valign=("|')[\s\S]*?\2([\s\S]*?>)/gi,"$1$3");e=e.replace(/(<td[\s\S]*?)nowrap=("|')[\s\S]*?\2([\s\S]*?>)/gi,"$1$3");e=e.replace(/(<td[\s\S]*?)nowrap([\s\S]*?>)/gi,"$1$3");e=e.replace(/(<col[\s\S]*?)width=("|')[\s\S]*?\2([\s\S]*?>)/gi,"$1$3");e=e.replace(/(<col[\s\S]*?)style=("|')[\s\S]*?\2([\s\S]*?>)/gi,"$1$3");if(BX.browser.IsOpera())e=e.replace(/REF\s+?_Ref\d+?[\s\S]*?MERGEFORMAT\s([\s\S]*?)\s[\s\S]*?<\/xml>/gi," $1 ");return e}};BXLEditorUtils=function(){this.oTune={};this.setCurrentEditorId("default")};BXLEditorUtils.prototype={setCurrentEditorId:function(e){this.curId=e},prepare:function(){if(!this.oTune[this.curId])this.oTune[this.curId]={buttons:[],ripButtons:{}}},addButton:function(e,t){if(!e||!e.id)return false;if(typeof t=="undefined")t=-1;this.prepare();this.oTune[this.curId].buttons.push({but:e,ind:t});return true},removeButton:function(e){this.prepare();this.oTune[this.curId].ripButtons[e]=true}};oBXLEditorUtils=new BXLEditorUtils;function BXFindParentElement(e,t){var i,r=[],s=[];while((e=e.parentNode)!=null)r[r.length]=e;while((t=t.parentNode)!=null)s[s.length]=t;var n,o=0,a=0;if(r.length<s.length){n=r.length;a=s.length-n}else{n=s.length;o=r.length-n}for(var l=0;l<n-1;l++){if(BXElementEqual(r[l+o],s[l+a]))return r[l+o]}return r[0]}window.BXFindParentByTagName=function(e,t){t=t.toUpperCase();while(e&&(e.nodeType!=1||e.tagName.toUpperCase()!=t))e=e.parentNode;return e};function SetAttr(e,t,i){if(t=="className"&&!BX.browser.IsIE())t="class";if(i.length<=0)e.removeAttribute(t);else e.setAttribute(t,i)}function BXCutNode(e){while(e.childNodes.length>0)e.parentNode.insertBefore(e.childNodes[0],e);e.parentNode.removeChild(e)}
//# sourceMappingURL=le_core.map.js